/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object;

import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.EndGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object.interfaces.Generatable;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.Point;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.path.MoveToPathElement;

/**
 *
 * @author Admin
 */
public class MoveToGenerator implements Generator,Generatable{

    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof MoveToPathElement)
            return true;
        else return false;
    }

    @Override
    public void generate(StringBuilder sb, Object o, int recursionLevel,Object original) {
        this.generateStart(sb);
        this.generatePoint(sb, (MoveToPathElement)o);
        this.generateUniqueAttributes(sb, o,recursionLevel);
        this.generateEnd(sb);
    }

    @Override
    public void generateStart(StringBuilder sb) {
        sb.append("MoveTo{\n");
    }

    @Override
    public void generateEnd(StringBuilder sb) {
       EndGenerator.generateEnd(sb);
    }
    /**
     * I think all pathElements will have absolute:true but I am not sure
     * @param sb
     * @param o
     */
    @Override
    public void generateUniqueAttributes(StringBuilder sb, Object o,int recursionLevel) {
        sb.append("absolute:true;\n");
    }

    private void generatePoint(StringBuilder sb,MoveToPathElement m){
        Point p=m.getPoints().get(0);
        sb.append("x:"+p.getHPos()+";\n");
        sb.append("y:"+p.getVPos()+";\n");
    }


}
